package com.olclass.web.service;

import com.olclass.web.dao.RoleRepository;
import com.olclass.web.domain.College;
import com.olclass.web.domain.Lesson;
import com.olclass.web.domain.Role;
import com.olclass.web.support.QueryParamUtil;
import com.olclass.web.support.QuerySpecification;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageRequest;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

/**
 * FileName: RoleService.java
 * Author:   Administrator
 * Date:     2021/3/22 19:53
 * Description:
 */
@Service
@Transactional
public class RoleService {

    @Autowired
    RoleRepository roleRepository;

    public Page<Role> queryByFilter(String filterParam, String sortParam, int start, int limit) {
        Page<Role> results = roleRepository.findAll(new QuerySpecification<Role>(filterParam),
                new PageRequest(start, limit, QueryParamUtil.parseSortParams(sortParam)));
        return results;
    }
    public void save(Role item){
        roleRepository.save(item);
    }

    public void delete(String id){
        roleRepository.delete(id);
    }

    public Role findById(String id){
        return  roleRepository.findById(id);
    }
}